#include<stdio.h>
int count(int number,int x){
	int count=0,a;
	while(number>10){
		a=number%10;
		number=number/10;
		if(a==x){
			count++;
		}
	}
	if(number==x){
		count++;
	}
	return count;
}
int main(){
	int number,x;
	scanf("%d %d",&number,&x);
	printf("%d",count(number,x));
	return 0;
}
